/*
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *      
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */
#include "Main.hpp"
#include "MapEditor.hpp"

cSave GlobalSave;
bool Running = true;
using namespace std;
void ShutDownProgram()
{
	Running = false;
	ShutdownMusic();
}
int FPS_Counter()
{
	static int fpscount;
	static int s_fps;
	static unsigned long lasttime;
	++fpscount;
	if( SDL_GetTicks() - lasttime >= 1000 ) 
	{
		lasttime = SDL_GetTicks();
		s_fps = fpscount;
		fpscount = 0;
	}
	
	return s_fps;
}
void ex_program(int sig) 
{
	ShutDownProgram();
}
#undef main
int main(int argc, char *argv[]) 
{
	//glutInit(&argc, (char**)argv);
	// This call allows us to catch ctrl+c which I use quite often to kill the program
	// Since this allows us to catch ctrl+c it shutdown audio correctly so we don't get error messages in the terminal
	//(void) signal(SIGINT, ex_program);
	if(argc >= 2)
		if(!strcasecmp(argv[1], "-m"))
			if(!MapEditor(argc, argv))
				return false;
	InitMusic(argc,argv);
	InitScreen(800, 600);
	GetInput();
	
	MainMenu();
	ShutDownProgram();
	return 0;
}
